# -*- coding: utf-8 -*-
"""
------------------------------------------------------------------------------
    File Name:  plt_demo
    Author   :  wanwei1029
    Date     :  2018/10/20
    Desc     :
    https://blog.csdn.net/Notzuonotdied/article/details/77876080
------------------------------------------------------------------------------
"""
import matplotlib.pyplot as plt
import numpy as np


def plt_2_line():
    x = np.linspace(-1, 1, 50)
    # 注意，x用range生成不行。
    y1 = 2 * x + 1
    y2 = 2 ** x + 1
    plt.figure(num=3, figsize=(8, 5))
    plt.plot(x, y2)
    plt.plot(x, y1,
             color='red',  # 线条的颜色
             linewidth=1.0,  # 线条的粗细
             linestyle='--'  # 线条的样式
             )
    plt.show()

def plt_from_list():
    """
    plt index坐标，值要不一样，比如想要0,1,2,3,4,5,1,1,2,3,4,5这样循环，但是最后x轴只会有0,1,2,3,4,5，所以index值要唯一
    :return:
    """
    a = list("abcdefghij")
    print(a)
    b = np.arange(100, 600, step=50)
    print(b)
    plt.plot(a, b)
    plt.show()

def demo():
    """
    """
    x = np.linspace(-1, 1, 50)
    y = 2 ** x + 1
    plt.plot(x, y)
    plt.xlabel("I am x")
    plt.ylabel("I am y")
    plt.show()


if __name__ == '__main__':
    test_method = "demo"
    if test_method == "demo":
        demo()
    elif test_method == "plt_from_list":
        plt_from_list()
    elif test_method == "plt_2_line":
        plt_2_line()
